<?php
// load configuration file
require_once('config.php');
// load error handling module
require_once('error_handler.php');

// Chat class that contains server-side chat functionality
class Profiel
{
  // database handler
  private $mMysqli;  
  
  // constructor opens database connection
  function __construct() 
  {   
    // connect to the database
    $this->mMysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);      
  }
 
  // destructor closes database connection  
  public function __destruct() 
  {
    $this->mMysqli->close();
  }
  
  //The postMessages method inserts a profile into the database
   
  public function postMessage($firstname, $lastname, $woonplaats, $email, $telefoon, $bio)
  {
  
    // escape the variable data for safely adding them to the database
    $firstname = $this->mMysqli->real_escape_string($firstname);
    $lastname = $this->mMysqli->real_escape_string($lastname);
    $woonplaats = $this->mMysqli->real_escape_string($woonplaats);
	$email = $this->mMysqli->real_escape_string($email);
	$telefoon = $this->mMysqli->real_escape_string($telefoon);
	$bio = $this->mMysqli->real_escape_string($bio);
    // build the SQL query that adds a new message to the server
    $query = 'INSERT INTO studentprofiel(voornaam, achternaam, woonplaats, email, telefoon, biography) ' .
             'VALUES ("' . $firstname . '" , "' . $lastname . '","' .$woonplaats . '","' .$email . '","' .$telefoon . '","' . $bio . '")'; 
    // execute the SQL query
    $result = $this->mMysqli->query($query);    
	echo "Registreren compleet.<br/>" ;
	echo "<a href=\"student.html\">terug naar home pagina...</a>" ;
}
	/*
  public function postMessage($user, $email)
  { 
	 // escape the variable data for safely adding them to the database
    $user = $this->mMysqli->real_escape_string($user);
    $email = $this->mMysqli->real_escape_string($email);
   
	
    // build the SQL query that adds a new message to the server
    $query = 'INSERT INTO users(user_name, email) ' .
             'VALUES ( "' . $user .'","'.$email . '")'; 
    // execute the SQL query
    $result = $this->mMysqli->query($query);      
  }
  */
}
?>
